/**
 * 项目名：phms3
 * 日期：    2019-11-23 18:57:25
 * Copyright (c) 2015- HTSC-版权所有
 */

package com.joysuch.wwyt.mh.entity;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import com.joysuch.wwyt.dataperm.annotation.DataPermissionField;
import com.joysuch.wwyt.dataperm.enums.DataPermissionFilterType;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Data
@Table(name = "wwyt_mh_major_hazard")
@SQLDelete(sql = "update wwyt_mh_major_hazard set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_mh_major_hazard set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")

public class MhMajorHazard implements java.io.Serializable {

    // columns START
    // ID
    private Long id;
    // 租户
    private Long tenentId;
    // 组织机构代码
    private String orgCode;
    // 统一编码
    private String code;
    // 名称
    private String name;
    // 描述
    private String description;
    // 所在位置
    private String location;
    // 防雷防静电设施是否定期接受检测
    private String antiThunderFacilityPeriodlyChecked;
    // 周边环境名称
    private String surroundingName;
    // 周边环境类型
    private String surroundingType;
    // 与危险源最近距离
    private Integer minDistance;
    // 周边环境人数
    private Integer personCountArround;
    // 重大危险源周边安全间距(m)
    private Integer surroundingSafeDistance;
    // 周边环境联系人
    private String surroundingContact;
    // 周边环境联系人电话
    private String surroundingContactPhone;
    // R值
    private Double rvalue;
    // 重大危险源等级
    private String level;
    //填表人
    private String writtenBy;
    // 创建时间
    private Date createTime;
    // 更新人
    private Long updateBy;
    // 更新时间
    private String updateTime;
    // 删除标记
    private String deleteFlag;
    // columns END
    // 投用时间
    private String startUseTime;
    // 风险区域ID
    @DataPermissionField(type = DataPermissionFilterType.JOIN_TABLE,
            sqlColumn = "risk_district_id", joinInfo = {"wwyt_risk_district", "id",
            "responsible_dept"})
    private Long riskDistrictId;

    //主要负责人
    private String responsibleUserId;

    //技术负责人
    private String technologyUserId;

    //操作负责人
    private String operationUserId;

    //附件
    private String attachment;

    //44不显示;1显示
    private Integer state;



    @Column(name = "technology_user_id")
    public String getTechnologyUserId() {
        return technologyUserId;
    }

    public void setTechnologyUserId(String technologyUserId) {
        this.technologyUserId = technologyUserId;
    }

    @Column(name = "operation_user_id")
    public String getOperationUserId() {
        return operationUserId;
    }

    public void setOperationUserId(String operationUserId) {
        this.operationUserId = operationUserId;
    }


    @Column(name = "responsible_user_id")
    public String getResponsibleUserId() {
        return responsibleUserId;
    }

    public void setResponsibleUserId(String responsibleUserId) {
        this.responsibleUserId = responsibleUserId;
    }

    @Column(name = "state")
    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    @Column(name = "RISK_DISTRICT_ID")
    public Long getRiskDistrictId() {
        return riskDistrictId;
    }

    public void setRiskDistrictId(Long riskDistrictId) {
        this.riskDistrictId = riskDistrictId;
    }

    @Column(name = "START_USE_TIME3", length = 64)
    public String getStartUseTime() {
        return startUseTime;
    }

    public void setStartUseTime(String startUseTime) {
        this.startUseTime = startUseTime;
    }

    public void setId(Long value) {
        this.id = value;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "Id", unique = true, nullable = false)
    public Long getId() {
        return this.id;
    }

    @Column(name = "TENENT_ID")
    public Long getTenentId() {
        return this.tenentId;
    }

    public void setTenentId(Long value) {
        this.tenentId = value;
    }

    @Column(name = "ORG_CODE", length = 100)
    public String getOrgCode() {
        return this.orgCode;
    }

    public void setOrgCode(String value) {
        this.orgCode = value;
    }

    @Column(name = "CODE", length = 20)
    public String getCode() {
        return this.code;
    }

    public void setCode(String value) {
        this.code = value;
    }

    @Column(name = "NAME")
    public String getName() {
        return this.name;
    }

    public void setName(String value) {
        this.name = value;
    }

    @Column(name = "DESCRIPTION")
    public String getDescription() {
        return this.description;
    }

    public void setDescription(String value) {
        this.description = value;
    }

    @Column(name = "LOCATION", length = 128)
    public String getLocation() {
        return this.location;
    }

    public void setLocation(String value) {
        this.location = value;
    }

    @Column(name = "ANTI_THUNDER_FACILITY_PERIODLY_CHECKED", length = 2)
    public String getAntiThunderFacilityPeriodlyChecked() {
        return this.antiThunderFacilityPeriodlyChecked;
    }

    public void setAntiThunderFacilityPeriodlyChecked(String value) {
        this.antiThunderFacilityPeriodlyChecked = value;
    }

    @Column(name = "SURROUNDING_NAME", length = 50)
    public String getSurroundingName() {
        return this.surroundingName;
    }

    public void setSurroundingName(String value) {
        this.surroundingName = value;
    }

    @Column(name = "SURROUNDING_TYPE", length = 50)
    public String getSurroundingType() {
        return this.surroundingType;
    }

    public void setSurroundingType(String value) {
        this.surroundingType = value;
    }

    @Column(name = "MIN_DISTANCE")
    public Integer getMinDistance() {
        return this.minDistance;
    }

    public void setMinDistance(Integer value) {
        this.minDistance = value;
    }

    @Column(name = "PERSON_COUNT_ARROUND")
    public Integer getPersonCountArround() {
        return this.personCountArround;
    }

    public void setPersonCountArround(Integer value) {
        this.personCountArround = value;
    }

    @Column(name = "SURROUNDING_SAFE_DISTANCE")
    public Integer getSurroundingSafeDistance() {
        return this.surroundingSafeDistance;
    }

    public void setSurroundingSafeDistance(Integer value) {
        this.surroundingSafeDistance = value;
    }

    @Column(name = "SURROUNDING_CONTACT", length = 12)
    public String getSurroundingContact() {
        return this.surroundingContact;
    }

    public void setSurroundingContact(String value) {
        this.surroundingContact = value;
    }

    @Column(name = "SURROUNDING_CONTACT_PHONE", length = 128)
    public String getSurroundingContactPhone() {
        return this.surroundingContactPhone;
    }

    public void setSurroundingContactPhone(String value) {
        this.surroundingContactPhone = value;
    }

    @Column(name = "R_VALUE")
    public Double getRvalue() {
        return this.rvalue;
    }

    public void setRvalue(Double value) {
        this.rvalue = value;
    }

    @Column(name = "LEVEL", length = 8)
    public String getLevel() {
        return this.level;
    }

    public void setLevel(String value) {
        this.level = value;
    }

    @Column(name = "WRITTEN_BY", length = 64)
    public String getWrittenBy() {
        return this.writtenBy;
    }

    public void setWrittenBy(String value) {
        this.writtenBy = value;
    }

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    public Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(Date value) {
        this.createTime = value;
    }

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    public Long getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(Long value) {
        this.updateBy = value;
    }

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME", length = 64)
    public String getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(String value) {
        this.updateTime = value;
    }

    @Column(name = "DELETE_FLAG", length = 2)
    public String getDeleteFlag() {
        return this.deleteFlag;
    }

    public void setDeleteFlag(String value) {
        this.deleteFlag = value;
    }

    private Set<MhMajorHazardChemProductRel> mhMajorHazardChemProductRels = new LinkedHashSet<>(0);

    @OneToMany(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @JoinColumn(name = "MAJOR_HAZARD_ID")
    public Set<MhMajorHazardChemProductRel> getMhMajorHazardChemProductRels() {
        return this.mhMajorHazardChemProductRels;
    }

    public void setMhMajorHazardChemProductRels(Set<MhMajorHazardChemProductRel> mhMajorHazardChemProductRels) {
        this.mhMajorHazardChemProductRels = mhMajorHazardChemProductRels;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId())
                .append("tenentId", getTenentId()).append("orgCode", getOrgCode()).append("code", getCode())
                .append("name", getName()).append("description", getDescription()).append("location", getLocation())
                .append("antiThunderFacilityPeriodlyChecked", getAntiThunderFacilityPeriodlyChecked())
                .append("surroundingName", getSurroundingName()).append("surroundingType", getSurroundingType())
                .append("minDistance", getMinDistance()).append("personCountArround", getPersonCountArround())
                .append("surroundingSafeDistance", getSurroundingSafeDistance())
                .append("surroundingContact", getSurroundingContact())
                .append("surroundingContactPhone", getSurroundingContactPhone()).append("rvalue", getRvalue())
                .append("level", getLevel()).append("writtenBy", getWrittenBy()).append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy()).append("updateTime", getUpdateTime())
                .append("deleteFlag", getDeleteFlag()).toString();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof MhMajorHazard == false)
            return false;
        if (this == obj)
            return true;
        MhMajorHazard other = (MhMajorHazard) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
